<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get interpreted size from ini shorthand syntax</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.ini-get.html">« ini_get</a></li>
      <li style="float: right;"><a href="function.ini-restore.html">ini_restore »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.info.html">PHP 选项/信息 函数</a></li>
    <li>Get interpreted size from ini shorthand syntax</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.ini-parse-quantity" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ini_parse_quantity</h1>
  <p class="verinfo">(PHP 8 &gt;= 8.2.0)</p><p class="refpurpose"><span class="refname">ini_parse_quantity</span> &mdash; <span class="dc-title">Get interpreted size from ini shorthand syntax</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.ini-parse-quantity-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>ini_parse_quantity</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$shorthand</code></span>): <span class="type">int</span></div>

  <p class="para rdfs-comment">
   Returns the interpreted size in bytes on success from an <a href="faq.using.html#faq.using.shorthandbytes" class="link">ini shorthand</a>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.ini-parse-quantity-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">shorthand</code></dt>

     <dd>

      <p class="para">
       Ini shorthand to parse, must be a number followed by an optional multiplier.

       The followig multipliers are supported: <code class="literal">k</code>/<code class="literal">K</code> (<code class="literal">1024</code>),
       <code class="literal">m</code>/<code class="literal">M</code> (<code class="literal">1048576</code>),
       <code class="literal">g</code>/<code class="literal">G</code> (<code class="literal">1073741824</code>).

       The number can be a decimal, hex (prefixed with <code class="literal">0x</code> or <code class="literal">0X</code>),
       octal (prefixed with <code class="literal">0o</code>, <code class="literal">0O</code> or <code class="literal">0</code>) or binary (prefixed with
       <code class="literal">0b</code> or <code class="literal">0B</code>)
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.ini-parse-quantity-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns the interpreted size in bytes as an <span class="type">int</span>.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.ini-parse-quantity-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   If the value cannot be parsed, or an invalid multiplier is used, an <strong><code>E_WARNING</code></strong> is raised.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.ini-parse-quantity-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-576">
    <p><strong>示例 #1 A few <span class="function"><strong>ini_parse_quantity()</strong></span> examples</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">ini_parse_quantity</span><span style="color: #007700">(</span><span style="color: #DD0000">'1024'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">ini_parse_quantity</span><span style="color: #007700">(</span><span style="color: #DD0000">'1024M'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">ini_parse_quantity</span><span style="color: #007700">(</span><span style="color: #DD0000">'512K'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">ini_parse_quantity</span><span style="color: #007700">(</span><span style="color: #DD0000">'0xFFk'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">ini_parse_quantity</span><span style="color: #007700">(</span><span style="color: #DD0000">'0b1010k'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">ini_parse_quantity</span><span style="color: #007700">(</span><span style="color: #DD0000">'0o1024'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">ini_parse_quantity</span><span style="color: #007700">(</span><span style="color: #DD0000">'01024'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">ini_parse_quantity</span><span style="color: #007700">(</span><span style="color: #DD0000">'Foobar'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">ini_parse_quantity</span><span style="color: #007700">(</span><span style="color: #DD0000">'10F'</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>

int(1024)
int(1073741824)
int(524288)
int(261120)
int(10240)
int(532)
int(532)

Warning: Invalid quantity &quot;Foobar&quot;: no valid leading digits, interpreting as &quot;0&quot; for backwards compatibility
int(0)

Warning: Invalid quantity &quot;10F&quot;: unknown multiplier &quot;F&quot;, interpreting as &quot;10&quot; for backwards compatibility
int(10)

</pre></div>
    </div>
   </div>
  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.ini-parse-quantity-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><span class="function"><a href="function.ini-get.html" class="function" rel="rdfs-seeAlso">ini_get()</a> - 获取一个配置选项的值</span></li>
  </ul>
 </div>

</div></div></div></body></html>